﻿@model HanGu.Entity.vwMemberContact
@{
    Layout = null;
    var AccessCusType = ViewData["AccessCusType"] as SelectList;
    var Parents = ViewData["Parents"] as SelectList;

    var SelectedParents = new List<string>();
    if (!string.IsNullOrEmpty(Model.Manager))
    {
        SelectedParents = Model.Manager.Split(',').ToList();
    }
    var action = Request["action"];
    var read = action != null && action == "read";
}
@*<script>
    $(function () { 

     $.validator.addMethod("CheckMember", function (value, element) {
                $this = $(element);
                var result = false;
               var array="@MvcHtmlString.Create(ViewData["Members"] as string)".split(",");               
               for(var i=0;i<array.length;i++)
               {
               if(array[i].indexOf(value)>=0)
               {result=true;break;}
               }
                return this.optional(element) || result;
            }, "请选择有效的客户名称！");
            
            $.validator.addClassRules({
                CheckMember: { CheckMember: true }                
            });

     $(".AutoComplete").AutoComplete({
        'data': @MvcHtmlString.Create(ViewData["Members"] as string)
        , 'width': 'auto'
            });
    });
</script>*@
<div class="pageContent">
    <form method="post" action="/CustomerInfo/MemberContact/create" class="pageForm required-validate"
    onsubmit="return validateCallback(this, mydialogAjaxDone);">
    <script>
        function SelectText(obj) {
            $this = $(obj).find("option:selected");
            $("#TypeName").val($this.text());
        }
    </script>
    @Html.ValidationSummary(true)
    <div class="pageFormContent" layouth="56">
        @Html.HiddenFor(model => model.ID)
        @Html.HiddenFor(model => model.MemberID)
        @Html.HiddenFor(model => model.TypeName)
        <p>
            <label>
                日期：</label>
            @Html.TextBoxFor(model => model.CreateTime, new { @class = "date", format = "yyyy-MM-dd HH:mm", @readonly = "true" })
            @Html.ValidationMessageFor(model => model.CreateTime)
        </p>
        <p>
            <label>
                形式：</label>
            @Html.DropDownListFor(model => model.Type, AccessCusType, HanGu.CRM.HelperCommon.SelectDefaultValue, new { @class = "required combox", onchange="SelectText(this)" })
            @Html.ValidationMessageFor(model => model.Type)
        </p>
        <p style="width: 100%; height: 200px">
            <label>
                内容：</label>
            @Html.TextAreaFor(model => model.Remark, new { @class = "required", @Style = "width:95%;height:200px" })
            @Html.ValidationMessageFor(model => model.Remark)
        </p>
        <p>
            <p style="width: 100%;">
                <label>
                    负责人：</label>
                @foreach (var item in Parents)
                {

                    <input name="Manager" class="checkbox required" id="Manager" style="magin-left: 5px;" type="checkbox" CHECKED="@SelectedParents.Contains((item.Value))" value="@item.Value"/>
                    @item.Text
                }
                @Html.ValidationMessageFor(model => model.Creator)</p>
        </p>
    </div>
    @if (Request["action"] != "view")
    {
        <div class="formBar">
            <ul>
                @if (!read)
                {
                    <li>
                        <div class="buttonActive">
                            <div class="buttonContent">
                                <button type="submit">
                                    提交</button></div>
                        </div>
                    </li>
                }
                <li>
                    <div class="button">
                        <div class="buttonContent">
                            <button type="button" class="close">
                                取消</button></div>
                    </div>
                </li>
            </ul>
        </div>
    }
    </form>
</div>
